/**
 * 
 */
package com.ubo.visu.model;

import java.util.ArrayList;
import java.util.Collection;

import com.ubo.visu.painter.node.IDrawableNode;
import com.ubo.visu.painter.node.INodePainter;

/**
 * @author saludegu
 * 
 */
public class ModelNode implements IDrawableNode {

	/**
	 * Nom du noeud.
	 */
	protected String mNameNode;

	/**
	 * Collection d'attributs.
	 */
	protected Collection<MemberAttribute> mAttributes;

	/**
	 * Collection d'attributs.
	 */
	protected Collection<MemberMethod> mMethods;

	/**
	 * Type de l'entité.
	 */
	protected EEntityType mEntityType;

	/**
	 * 
	 * Constructor
	 * 
	 * @param idNode
	 * @param nameNode
	 */
	public ModelNode(String nameNode, EEntityType type) {
		mNameNode = nameNode;
		mEntityType = type;
	}

	/**
	 * Ajout d'un modelAttribute au node.
	 * 
	 * @param attr
	 */
	public void addModelAttribute(MemberAttribute attr) {
		if (mAttributes == null)
			mAttributes = new ArrayList<MemberAttribute>();
		mAttributes.add(attr);
	}

	/**
	 * Ajout d'un modelAttribute au node.
	 * 
	 * @param attr
	 */
	public void addAllModelAttribute(MemberAttribute... tabAttr) {
		if (mAttributes == null)
			mAttributes = new ArrayList<MemberAttribute>();
		for (MemberAttribute attr : tabAttr)
			mAttributes.add(attr);
	}

	/**
	 * Ajout d'un modelMethod au node.
	 * 
	 * @param attr
	 */
	public void addModelMethod(MemberMethod attr) {
		if (mMethods == null)
			mMethods = new ArrayList<MemberMethod>();
		mMethods.add(attr);
	}

	/**
	 * Ajout d'un modelMethod au node.
	 * 
	 * @param attr
	 */
	public void addAllModelMethod(MemberMethod... tabAttr) {
		if (mMethods == null)
			mMethods = new ArrayList<MemberMethod>();
		for (MemberMethod attr : tabAttr)
			mMethods.add(attr);
	}

	/**
	 * Getter de la collection d'attributs.
	 * 
	 * @return
	 */
	public Collection<MemberAttribute> getAttributes() {
		return mAttributes;
	}

	/**
	 * Getter de la collection de m�thodes.
	 * 
	 * @return
	 */
	public Collection<MemberMethod> getMethodes() {
		return mMethods;
	}

	/**
	 * @return the mNameNode
	 */
	public String getNameNode() {
		return mNameNode;
	}

	/**
	 * @see com.ubo.visu.painter.node.IDrawableNode#paint(com.ubo.visu.painter.node.INodePainter)
	 */
	@Override
	public void paint(INodePainter painter) {
		painter.paint(this);
	}

	public EEntityType getEntityType() {
		return mEntityType;
	}

}
